package com.zoffy.ybuhelper.dao;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;
import com.zoffy.ybuhelper.pojo.entity.Category;

import java.util.List;

@Dao
public interface CategoryDao {
    @Insert
    void insert(Category category);
    @Query("select id,name from category")
    List<Category> getAll();
    @Query("DELETE FROM category WHERE id=:id")
    void deleteById(Integer id);
    @Query("SELECT id,name FROM  category WHERE category.id in (SELECT category_id FROM menu_category WHERE menu_id=:id)")
    List<Category> queryByMenuId(Integer id);
    @Query("Update category SET name=:name WHERE id=:id")
    void updateName(Integer id,String name);
    @Query("SELECT id,name FROM category WHERE id=:id")
    Category get(Integer id);

}
